﻿using System;
using System.Data;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using CE.Promotion;
using CE.User;
using CE.Global;
using CE.Mail;
using Facebook_Graph_Toolkit;

public partial class promo_promo_coming_soon : SocialPage
{
    //protected void Page_PreInit(object sender, EventArgs e)
    //{
    //    //ExtendedPermissions = "email,user_birthday,user_relationships, publish_stream";
    //    ExtendedPermissions = "email,user_birthday,user_relationships";
    //    //RequireLogin = true;   Set to true if the page must access the user's Facebook info (i.e. Api is never null)
    //}

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
           
        }


    }


    protected void btnSubscribe_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            UserSubscriber _usersub = new UserSubscriber();
            UserSubscriberDB _usersubdb = new UserSubscriberDB();
            _usersub.Email = txtEmailSubscribe.Text;
            _usersub.Info1 = txtNameSubscribe.Text;
            _usersub.SubscribeType = "PR";
            if (_usersubdb.Insert(_usersub) > 0)
            {
                divSuccess.Visible = true;
                txtEmailSubscribe.Enabled = false;
                txtNameSubscribe.Enabled = false;
                btnSubscribe.Enabled = false;
            }

            //if (_usersubdb.AlreadyExist(_usersub.Email) > 0)
            //{
            //    txtEmailSubscribe.Enabled = false;
            //    divSuccess.InnerHtml = "You already subscribed. Thank you.";
            //    divSuccess.Visible = true;
            //}
        }
    }

    protected void CheckIsExisting(object sender, ServerValidateEventArgs args)
    {
        UserSubscriber _usersub = new UserSubscriber();
        UserSubscriberDB _usersubdb = new UserSubscriberDB();
        _usersub.Email = txtEmailSubscribe.Text;
        if (_usersubdb.AlreadyExist(_usersub.Email) > 0)
        {
            //lblMessageSubscribe.Text = "Your email is already existing in our list!";
            args.IsValid = false;
        }
        else
        {
            args.IsValid = true;
        }

    }

    protected void FbAuthClick(object sender, EventArgs e)
    {
        if (Api == null) RedirectToFacebookAuthorization();


    }
}
